export const initTime = (value: string): string => {
  const tt = new Date(value)
  const days = (new Date().getTime() - new Date(value).getTime()) / 86400000
  const today = new Date().getDate()
  const year = tt.getFullYear()
  const mouth = tt.getMonth() + 1
  const day = tt.getDate()
  const time = tt.getHours() < 10 ? '0' + tt.getHours() : tt.getHours()
  const min = tt.getMinutes() < 10 ? '0' + tt.getMinutes() : tt.getMinutes()
  let result = ''
  const offset = Math.abs(today - day)
  if (days < 4 && offset < 4) {
    if (offset === 0) {
      result = '今天' + time + ':' + min
    } else if (offset === 1) {
      result = '昨天' + time + ':' + min
    } else if (offset === 2) {
      result = '前天' + time + ':' + min
    }
  } else {
    result = year + '-' + mouth + '-' + day + ' ' + time + ':' + min
  }
  return result
}
